package com.nondo.rdp.finance.repository.product;

import java.util.Optional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.nondo.rdp.core.common.StatusConstant;
import com.nondo.rdp.finance.domain.product.SecurityOpenUser;

public interface SecurityOpenUserRepository extends JpaRepository<SecurityOpenUser, Long>, JpaSpecificationExecutor<SecurityOpenUser> {
    @Query("select a from SecurityOpenUser a where a.id=:id and delFlag = '" + StatusConstant.DEL_FLAG_NORMAL + "'")
    Optional<SecurityOpenUser> findOne(@Param("id") int id);

    @Modifying
    @Query("update SecurityOpenUser set delFlag='" + StatusConstant.DEL_FLAG_DELETE + "' where id = ?1")
    void deleteById(Long id);

    SecurityOpenUser save(SecurityOpenUser activity);

    @Modifying
    @Query("update SecurityOpenUser set title=?1,body=?2 where id = ?3")
    void update(String title, String body, Long id);
}
